<floatFuncInterfaces>

	Each floatFunc has some constant size which is known at all times.

	javaFloatFunc: Java object with a function which operates on a double array, with some other parameter(s) to tell which part(s) of the array. I'm not sure of the parameters.
	
	interpFloatFunc: Array of int that representes some hard-coded action, like a = b + c, but does not need a function call by itself because it is interpreted.
	
	
	whole double array of the correct size.
	
	double array at least the correct size and int startIndex.
	
	double array and array of int index the correct size.
	
	
	
	This stuff can be decided faster if this question is answered...
	Whats the best way to define a function which keeps state (in some double array probably)
	and decays a few vars slowly, depending on if sine of some increasing value is less than .5 or not,
	and speed of the increasing value changes based on that sine?
	
	First, define it as Java code...
	final double someNumber = 7.2, someFraction = .5; //probably should do the same for the other constants
	double increasingValue = 5.9;
	double speed = .05;
	double x = someNumber;
	while(many times...){ //each iteration equals a call of the floatFunc
		double s = Math.sin(increasingValue);
		increasingValue += speed;
		if(s < someFraction){
			speed = speed*.99 + x*.01;
		}else{
			speed = speed*1.01 - x*.01;
		}
		x = x*.989 + .01*7.2 + .001*s;
	}
	???
	
	Then, define it as a floatFunc, for the purpose of deciding what a floatFunc is...
	d = [someNumber=7.2, increasingValue=5.9, speed=.05, x=7.2, s, 1.01, .01, .99, .989, .001, booleanResult]
	     0               1                    2          3      4  5     6    7    8     9     10
	theFloatFunc = {
		Read [1] do sine write [4]. //double s = Math.sin(increasingValue);
		Read [1] read [2] do + write [1]. //increasingValue += speed;
		Read [4] read [indexOf.5] do < write [10]. //if(s < someFraction)
		//This is the hard part. How to do control-flow? I dont like "goto".
		//A stack may work well for calling things in a global array recursively,
		//and it could be used for loops the same way they would be done in assembly language.
		Read [1] readFunc indexOfIfTrueCode ?read...doubles? readFunc indexOfIfFalseCode ?read...doubles? do IFELSE ?write...some...doubles?
		//Thats too complex and keeps code spread out in a global array, but it may be necessary for control-flow.
		//What is readFunc?
		//It may be more efficient to keep the funcs connected all the time and only read the doubles.
		//Maybe interpFloatFuncs should stay as a tree, and each have int indexs, but dynamicly be executed on an array.
		???
	}
	
	<tooSlow>
		Recursively using int arrays to find position in a common float array is slow.
	
		Copying floats into a new array each recursive call is slow.
	</tooSlow>
	
	Compiling java code or creating it with Javassist at runtime is fast, but complex.
	I need a way to interpret the code and see if it works in the most basic way before doing that.
	
	A float array used as a stack may be the fastest way.
	Each recursive call, copy multiple floats higher in the array and point the function to where those start.
	When it returns, copy multiple floats from the array to the range of array the caller is using (below it).
	For example, a function that swaps 2 floats is called on the first and last of [5,6,7,8.9]:
	Stack is [5,6,7,8.9,...]
	Copy 2 floats to end, and allow 1 temp index at end. Stack is: [5,6,7,8.9,5,8.9,tempNotYetUsed,...]
	Run the swap function. Stack is: [5,6,7,8.9,8.9,5,...]
	Copy the 2 floats back. Stack is: [8.9,6,7,5,...].
	Then the caller function continues.
	
	I choose the stack instead of multiple arrays. Its fast enough to do a few million func calls per second.
	
	Each func call has to start at some index. How does it get that index?
	For a Java object, a function works well: public void run(int startIndex, double d[]);
	But for interpreted funcs like +, -, *, sine, etc how should it be done?
	
	Maybe the first 128 numbers should be hard-coded as simple 1 or 2 parameter functions.
	For example, if you push 2 floats, execute (int)'+', then it uses those 2 floats
	and leaves 1 float on the stack, and you must pop that float right after that.
	In the same function which interprets those 128 indexs, it should interpret
	higher indexs than that as being combinations of those 128 things and/or
	Java objects which have a function similar to this:
	public void run(int startIndex, double d[]);
	
	AudivolvStreams could be represented as these types of things, and use the stack.
	For example, starting at index x, set d[x] to mouseX and d[x+1] to mouseY.
	
	The (int)'+' could be stored with 3 small ints. 2 ints tell where to copy the parameters from
	and 1 tells where to copy the returned float to. That is complex. It could instead
	be 2 push (int)'(' functions, 1 (int)'+' function, and 1 pop (int)')' function.
	The push and pop functions would have be optimized.
	The main advantage is you can often use the returned float of one func
	as the parameter of the next func without copying it.
	
	This stack-based stuff is similar to a Java JVM stack.
	
	<importantQuestion>
		Since I'm allowing multiple output floats from a func,
		should I simplify it and require that input size equals output size?
		???
	</importantQuestion>
	
	<importantQuestion>
		Control-flow is more complex. How should IFELSE be done?
		That requires I choose how code is represented.
		???
	</importantQuestion>
	
	To answer these questions, it would help to define a Human-usable syntax
	for writing things that would compile down to this stack-based stuff.
	
	<question>
		Would Codesimian syntax work? Example: if#i(sine(x) i 0)
		Allowing very slow code just for this example, how would that example be in memory?
	</question>
	
	<question>
		Should a SimilarToCodesimianNode have
		stateful child SimilarToCodesimianNode list and stateless float list?
		That would allow recursion while child list does not change.
		<question>
			In the same SimilarToCodesimianNode (or group of them?),
			should some floats be stateful and others stateless?
		</question>
		<possibleAnswer>
			public class SomeNode implements FloatFunc{
				private SomeNode childs[];
				public void run(int startIndex, double d[]);
			}
		</possibleAnswer>
	</question>
	
	<question>
		Should 2 stacks be used, 1 for floats and 1 for DualStackNodes?
		<possibleJavaCode>
			public interface DualStackNode{
				public void run(int dIndex, double d[], int nIndex, DualStackNode n[]);
			}
		</possibleJavaCode>
		How would the simple code if#i(sine(x) i 0) be written as a DualStackNode?
		doSine = [sineDSN, ???this doesnt make as much sense???]
		theIf = [ifDSN, sineDSN, theIf, constFloatDSN]
		Should a func have floats OR funcs as parameters but never both?
	</question>
	
	It would be very slow and very simple, to define a tree where every object
	individually has a constant quantity of floats and constant quantity of object childs,
	and to map a float array to floats in the tree in depth-first order.
	Find that mapping rarely and use it many times until it changes.
	That would obey the definition of a NODE if
	it did not depend on the order of its child nodes and floats.
	An IFELSE could have the IF and ELSE conditions as 2 size-1 arrays,
	but then it could only be combined with nodes of the same type,
	because a NETWORK can not have more than 1 type of node.
	
	Should IFELSE be a network of 2 nodes, sorted the normal network way,
	and the condition of the IFELSE somehow sorts the right node first?
	That network could be a Java class hard-coded to be efficient for IFELSE.
	
	For a long time, I've been planning to add the feature of connecting nodes
	of 1 network to nodes of a different network so they always execute in those pairs,
	without sharing any code or data between them.
	Maybe thats a good way to connect the IFELSE to 2 code paths.
	
	Maybe a sequence of funcs (or code actions of any kind) should be a network
	where they are sorted in that order, and the nodes change order in round-robin order
	by decreasing their value by some constant each time the node is executed.
	
	Or maybe a sequence of funcs (or code actions of any kind) should be a network
	where each node has a size 1 array containing the next node in the sequence,
	and when the nodeFunc runs, it decreases the sort value of the current node and increases
	the sort value of its child.
	
	What optimizations can be done on small hard-coded networks like those described above
	for IFELSE and SEQUENCE_OF_CODE?
	
	Should a network have or use a java.util.Collection of nodes?
	Or should it be defined as its own simpler interface?
	
	//Example not to be taken seriously:
	public interface Network{
		
		/** quantity of nodes */
		public int size();
		
		/** order of nodes usually changes in every call of run() */
		public Object[] firstNode();
		
		/** returns the NodeFunc without calling it. It should be called on the first node of this network. */
		public NodeFunc nodeFunc();
		
		/** executes 1 node and changes at most that node and its childs */
		//Is this needed, given that it mostly calls nodeFunc on the first nod? public void run();
		
		//or this func instead? public void run(Object oneNode[]);
	}
	
	NodeFunc and Network are probably too complex to merge
	with the func that NodeFunc calls many times per node execution.
	
	<question>
		Should trees of objects similar to codesimian.CS trees be the simple functions,
		except for 1 difference: Some (or all?) of the float parameters are instead pointers
		into a shared float array?
		
		Example: +(3.3 *(4.4 sine(x)) 5)
		would be something like this instead:
		+(floatPtr0 *(floatPtr1 sine(floatPtr2)) floatPtr3)
		
		The + may have to be a specific type of + that knows which parameters are object
		and which are float, but that can be avoided by having a floatPointer object
		instead of the floats directly.
		
		Error, +(floatPtr0 *(floatPtr1 sine(floatPtr2)) floatPtr3) requires + and * return a float,
		but returning is not allowed. Modifying the float a floatPtr points at is allowed.
		A floatPtr may be an int or a Java object, I dont know yet.
		
		This is wrong also, because it does not run the * the right way:
		+(floatPtr0 floatPtr1 *(floatPtr3 floatPtr2 sine(floatPtr3)) floatPtr4)
		
		floatArray is: [...todo write some numbers here...].
		tree of code objects is:
		do(
			do(
				sine(0 1)
				*(0 0 2)
			)
			do(
				+(0 0 3)
				+(0 0 4)
			)
		)
	</question>
	
	Example Java code:
	double a = .1;
	double b = 0;
	double c = .9;
	double d = .03;
	double e = 0;
	do{
		b = Math.sin(a);
		a = a + d;
		e = b<c ? 1 : 0;
	}while(0 < e);
	Example Audivolv code that does the same:
	The floatArray is: [.1 0 .9 .03 0].
	do#theLoop(
		do(
			sine(1 0)
			+(0 0 3)
		)
		do(
			<f(4 1 2)
			if(4 theLoop)
		)
	)
	
	Thats a recursive function but I did not define if the floats are reused or copied higher in the stack.
	Should it be defined as a function with parameters that point at floats?
	
	do#theLoop{
		do{
			sine{1 0}
			+{0 0 3}
		}
		do{
			<f{4 1 2}
			if{
				4
				do9{
					pushfFrom(0)
					pushfFrom(1)
					pushfFrom(2)
					pushfFrom(3)
					pushfFrom(4)
					theLoop
					popfTo(0)
					popfTo(1)
					popfTo(2)
					popfTo(3)
					popfTo(4)
				}
			}
	 	}
	}
	
	That code is complex and easy to break. Try something smaller:
	
	do#theLoop{
		do{
			sine{1 0}
			+{0 0 3}
		}
		do{
			<f{4 1 2}
			if{
				4
				theLoop(0 1 2 3 4) //WHAT DOES THIS MEAN???
			}
	 	}
	}
	
	Try to write the exponentially slow algorithm for fibonacci, and optimize it later:
	
	do#fibonacci{
		do{
			fibonacci(0 1)
			fibonacci(3 2)
		}
		+(0 0 3)
	}
	
	That does not end the recursion, but it would be done similarly.
	It also confuses index with value. Try again...
	
	A function needs to define
	* quantity of float parameters
	* quantity of temporary float parameters needed during execution
	* quantity of floats returned
	
	Fibonacci should have 1 parameter float (rounded to int) and 1 returned float.
	
	floatFunc(0_returned 1_input 2_temp 3_temp 4_constantOne 5_constantTwo)#fibonacci{
		do{
			do{
				-(2_temp 1_input 4_constantOne)
				-(3_temp 1_input 5_constantTwo)
			}
			do{
				do{
					fibonacci(2_temp 2_temp 4_constantOne 4_constantOne 4_constantOne 5_constantTwo)
					fibonacci(3_temp 3_temp 4_constantOne 4_constantOne 4_constantOne 5_constantTwo)
				}
				+(0_returned 2_temp 3_temp)
			}
		}
	}
	
	That recursion takes too many parameters.
	
	For now, it may help to build the most basic things in Java,
	and do not use recursion yet. Create a simple way to evolve functions
	that do not call other functions and do read and write floats in an array,
	and use a few of those in sequence, on different combinations of arrays in a node,
	as a nodeFunc.

</floatFuncInterfaces>